/*
** 图片宽度比例
***
**
*/
(function($){
	$.fn.ImgRatio = function(options){
		var $this = $(this);
		var ClassName = $this.attr("class");
		var Img = $this.find("img");
		var ImgW = 0, ImgH = 0;
		var PW = $this.width();
		var PH = $this.height();
			Img.each(function(i, o) {
				ImgW = $(o).width();
				ImgH = $(o).height();
				if(ClassName == "il-img"){
					PW = ImgW/ImgH>=1.6?569:275;
					$(o).parents("."+ClassName).width(PW);	//控制父层宽度
					$(o).parents("."+ClassName).parent().width(PW);	//IE 7 宽度控制
				}
				var Ppre = PW/PH;
				var Pimg = ImgW/ImgH;
				
				if(Pimg>=Ppre){	//宽大于高
					ImgW = PH*ImgW/ImgH;
					ImgH = PH;
					$(o).width(ImgW).height(ImgH).css("marginLeft",(PW-ImgW)/2+"px");
				}
				else if(Pimg<Ppre){	//宽大于高
					ImgH = PW*ImgH/ImgW;
					ImgW = PW;
					$(o).width(ImgW).height(ImgH).css("marginTop",(PH-ImgH)/2+"px");
				}
			});
		//return this.each(function(){
		//});
	}
})(jQuery)